package com.unittec.zk.provider.flowable.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.unittec.zk.provider.flowable.domain.FlowNextDto;
import com.unittec.zk.provider.flowable.service.IFlowTaskService;
import com.unittec.zk.provider.log.Log;
import com.unittec.zk.provider.utils.ValidationUtils;
import com.unittec.zk.sdk.auth.domain.SysRoleDto;
import com.unittec.zk.sdk.auth.domain.SysUserRes;
import com.unittec.zk.sdk.flowable.domain.FlowNext;
import com.unittec.zk.sdk.flowable.domain.FlowViewerDto;
import com.unittec.zk.sdk.flowable.request.*;
import com.unittec.zk.sdk.flowable.response.*;
import com.unittec.zk.sdk.root.domain.GatewayRequest;
import com.unittec.zk.sdk.root.domain.Result;
import com.unittec.zk.sdk.root.enums.BizCode;
import com.unittec.zk.sdk.root.enums.BizCodeEnum;
import com.unittec.zk.sdk.root.enums.ErrorEnum;
import com.unittec.zk.sdk.root.internal.exception.BusinessException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.flowable.bpmn.model.UserTask;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

@Api(tags = "工作流流程任务管理")
@RestController
public class FlowTaskController {
    @Autowired
    private IFlowTaskService flowTaskService;

    @Autowired
    private Log log;

    @RequestMapping(value = "/666031", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "我发起的流程", notes = "我发起的流程")
    public Result<Res666031> myProcess(@RequestBody GatewayRequest<Req666031> req){
        log.debug(req, "myProcess  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666031 res666031 = null;
        try {
            Req666031 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666031 = new Res666031();
            Page page = flowTaskService.myProcess(content.getCurrent().intValue(), content.getSize().intValue());
            res666031.setPage(page);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "myProcess {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666031);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666032", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "取消申请", notes = "取消申请")
    public Result<Res666032> stopProcess(@RequestBody GatewayRequest<Req666032> req){
        log.debug(req, "stopProcess  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666032 res666032 = null;
        try {
            Req666032 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666032 = new Res666032();
            flowTaskService.stopProcess(content.getFlowTaskVo());
            res666032.setContent("取消申请成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "stopProcess {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666032);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666033", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "撤回流程", notes = "撤回流程")
    public Result<Res666033> revokeProcess(@RequestBody GatewayRequest<Req666033> req){
        log.debug(req, "revokeProcess  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666033 res666033 = null;
        try {
            Req666033 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666033 = new Res666033();
            flowTaskService.revokeProcess(content.getFlowTaskVo());
            res666033.setContent("撤回流程成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "revokeProcess {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666033);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666034", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取待办列表", notes = "获取待办列表")
    public Result<Res666034> todoList(@RequestBody GatewayRequest<Req666034> req){
        log.debug(req, "todoList  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666034 res666034 = null;
        try {
            Req666034 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666034 = new Res666034();
            Page page = flowTaskService.todoList(content.getCurrent().intValue(), content.getSize().intValue());
            res666034.setPage(page);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "todoList {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666034);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666035", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取已办任务", notes = "获取已办任务")
    public Result<Res666035> finishedList(@RequestBody GatewayRequest<Req666035> req){
        log.debug(req, "finishedList  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666035 res666035 = null;
        try {
            Req666035 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666035 = new Res666035();
            Page page = flowTaskService.finishedList(content.getCurrent().intValue(), content.getSize().intValue());
            res666035.setPage(page);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "finishedList {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666035);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666036", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "流程历史流转记录", notes = "流程历史流转记录")
    public Result<Res666036> flowRecord(@RequestBody GatewayRequest<Req666036> req){
        log.debug(req, "flowRecord  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666036 res666036 = null;
        try {
            Req666036 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666036 = new Res666036();
            Map<String,Object> map = flowTaskService.flowRecord(content.getProcInsId(),content.getDeployId());
            res666036.setObj(map);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "flowRecord {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666036);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }


    @RequestMapping(value = "/666037", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取流程变量", notes = "获取流程变量")
    public Result<Res666037> processVariables(@RequestBody GatewayRequest<Req666037> req){
        log.debug(req, "processVariables  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666037 res666037 = null;
        try {
            Req666037 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666037 = new Res666037();
            Map<String,Object> map = flowTaskService.processVariables(content.getTaskId());
            res666037.setObj(map);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "processVariables {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666037);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666038", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "审批任务", notes = "审批任务")
    public Result<Res666038> complete(@RequestBody GatewayRequest<Req666038> req){
        log.debug(req, "complete  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666038 res666038 = null;
        try {
            Req666038 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666038 = new Res666038();
            String rs = flowTaskService.complete(content);
            res666038.setContent(rs);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "complete {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666038);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666039", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "驳回任务", notes = "驳回任务")
    public Result<Res666039> taskReject(@RequestBody GatewayRequest<Req666039> req){
        log.debug(req, "taskReject  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666039 res666039 = null;
        try {
            Req666039 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666039 = new Res666039();
            flowTaskService.taskReject(content.getFlowTaskVo());;
            res666039.setContent("驳回任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "taskReject {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666039);
        } else {
            return Result.error(req, bizCodeEnum);
        }

    }

    @RequestMapping(value = "/666040", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "退回任务", notes = "退回任务")
    public Result<Res666040> taskReturn(@RequestBody GatewayRequest<Req666040> req){
        log.debug(req, "taskReturn  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666040 res666040 = null;
        try {
            Req666040 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666040 = new Res666040();
            flowTaskService.taskReturn(content.getFlowTaskVo());;
            res666040.setContent("退回任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "taskReturn {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666040);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666041", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取所有可回退的节点", notes = "获取所有可回退的节点")
    public Result<Res666041> findReturnTaskList(@RequestBody GatewayRequest<Req666041> req){
        log.debug(req, "findReturnTaskList  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666041 res666041 = null;
        try {
            Req666041 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666041 = new Res666041();
            List<UserTask> userTaskList = flowTaskService.findReturnTaskList(content.getFlowTaskVo());
            res666041.setList(userTaskList);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "findReturnTaskList {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666041);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666042", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除任务", notes = "删除任务")
    public Result<Res666042> delete(@RequestBody GatewayRequest<Req666042> req){
        log.debug(req, "delete  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666042 res666042 = null;
        try {
            Req666042 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666042 = new Res666042();
            flowTaskService.deleteTask(content.getFlowTaskVo());
            res666042.setContent("删除任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "delete {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666042);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666043", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "认领/签收任务", notes = "认领/签收任务")
    public Result<Res666043> claim(@RequestBody GatewayRequest<Req666043> req){
        log.debug(req, "claim  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666043 res666043 = null;
        try {
            Req666043 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666043 = new Res666043();
            flowTaskService.claim(content.getFlowTaskVo());
            res666043.setContent("认领/签收任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "claim {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666043);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666044", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "取消认领/签收任务", notes = "取消认领/签收任务")
    public Result<Res666044> unClaim(@RequestBody GatewayRequest<Req666044> req){
        log.debug(req, "unClaim  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666044 res666044 = null;
        try {
            Req666044 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666044 = new Res666044();
            flowTaskService.unClaim(content.getFlowTaskVo());
            res666044.setContent("取消认领/签收任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "unClaim {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666044);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666045", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "委派任务", notes = "委派任务")
    public Result<Res666045> delegate(@RequestBody GatewayRequest<Req666045> req){
        log.debug(req, "delegate  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666045 res666045 = null;
        try {
            Req666045 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666045 = new Res666045();
            flowTaskService.delegateTask(content.getFlowTaskVo());
            res666045.setContent("委派任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "delegate {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666045);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666046", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "转办任务", notes = "转办任务")
    public Result<Res666046> assign(@RequestBody GatewayRequest<Req666046> req){
        log.debug(req, "assign  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666046 res666046 = null;
        try {
            Req666046 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666046 = new Res666046();
            flowTaskService.assignTask(content.getFlowTaskVo());
            res666046.setContent("转办任务成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "assign {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666046);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666047", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取下一节点", notes = "获取下一节点")
    public Result<Res666047> getNextFlowNode(@RequestBody GatewayRequest<Req666047> req){
        log.debug(req, "getNextFlowNode  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666047 res666047 = null;
        try {
            Req666047 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666047 = new Res666047();
            FlowNextDto flowNextDto = flowTaskService.getNextFlowNode(content);
            //type vars userList roleList
            if(flowNextDto != null){
                res666047.setType(flowNextDto.getType());
                res666047.setVars(flowNextDto.getVars());
                res666047.setUserList(flowNextDto.getUserList());
                res666047.setRoleList(flowNextDto.getRoleList());
            }
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "getNextFlowNode {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666047);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666048", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "导出流程图", notes = "导出流程图")
    public Result<Res666048> genProcessDiagram(@RequestBody GatewayRequest<Req666048> req){
        log.debug(req, "genProcessDiagram  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666048 res666048 = null;
        OutputStream os = null;
        BufferedImage image = null;
        try {
            Req666048 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666048 = new Res666048();
            InputStream inputStream =  flowTaskService.diagram(content.getProcessId());
            image = ImageIO.read(inputStream);
            content.getResponse().setContentType("image/png");
            os = content.getResponse().getOutputStream();
            if (image != null) {
                ImageIO.write(image, "png", os);
            }
            res666048.setContent("导出流程图成功");
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }finally {
            try {
                if (os != null) {
                    os.flush();
                    os.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        log.debug(req, "genProcessDiagram {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666048);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

    @RequestMapping(value = "/666049", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "生成流程图", notes = "生成流程图")
    public Result<Res666049> getFlowViewer(@RequestBody GatewayRequest<Req666049> req){
        log.debug(req, "getFlowViewer  {} ,param {}", "begin", JSON.toJSONString(req.getContent()));
        BizCodeEnum bizCodeEnum = BizCode.ERROR;
        Res666049 res666049 = null;
        try {
            Req666049 content = req.getContent();
            ValidationUtils.validateEntityStr(content);
            res666049 = new Res666049();
            List<FlowViewerDto> flowViewerDtoList = flowTaskService.getFlowViewer(content.getProcInsId());
            res666049.setList(flowViewerDtoList);
            bizCodeEnum = BizCode.SUCCESS;
        } catch (Exception e) {
            log.error(req, e.toString(), e);
            if (e instanceof BusinessException) {
                return Result.error(req, e.getMessage());
            } else {
                return Result.error(req, ErrorEnum.QUERY_ERROR.getErrorMessage());
            }
        }
        log.debug(req, "getFlowViewer {}  ", "end");
        if (bizCodeEnum == BizCode.SUCCESS) {
            return Result.success(req, res666049);
        } else {
            return Result.error(req, bizCodeEnum);
        }
    }

}
